<?php
namespace Home\Controller;
header("Content-Type:text/html;charset=utf-8");
use Think\Controller;
class CommonController extends Controller {
    public function _before_index(){
    	if(!session('user')){
    		if(!session('webisopens')){
                session('[start]');
                session('webisopens',null);
                session('webisopens', 1);
    			$this->redirect('Home/Index/index');
    		}
    	}else{
    		if(!session('webisopens')){
                session('[start]');
                session('webisopens',null);
                session('webisopens', 1);
    			$this->redirect('Home/Index/main');
    		}
    	}
    }


    /* 获取服务器信息（获取服务器性能CPU、内存、硬盘等使用率） */
    public function sysinfos(){

        $os = explode(" ", php_uname());
        $stime = date("Y-n-j H:i:s");
        $df = round(@disk_free_space(".")/(1024*1024*1024),3);
        $dt = round(@disk_total_space(".")/(1024*1024*1024),3);
        if('/'==DIRECTORY_SEPARATOR ){
            $this->assign('osname',$os[1]);
        }else{
            $this->assign('osname',$os[2]);
        }

        $dfdt = $df / $dt * 100;
        $dfdt = sprintf("%.2f",substr(sprintf("%.3f", $dfdt), 0, -2));
        $this->assign('stime',$stime);
        $this->assign('df',$df);
        $this->assign('dt',$dt);
        $this->assign('dfdt',$dfdt);

    }

}